#!/bin/sh -e

./configure \
    --prefix=/usr \
    --with-modules \
    --with-x-toolkit=gtk3 \
    --with-pgtk \
    --without-rsvg \
    --without-dbus \
    --with-xpm=no \
    --with-gnutls=yes

mkdir -p "$1/usr/share/emacs/site-lisp"
cat << EOF > "$1/usr/share/emacs/site-lisp/site-start.el"
;; GnuTLS configuration
;; In Carbs, CA certificates are installed to /etc/certificates
(with-eval-after-load 'gnutls
  (setq gnutls-verify-error   t
        gnutls-min-prime-bits 2048
        gnutls-trustfiles     '("/etc/certificates/cert.pem")
))

(setq-default shr-blocked-images ".*\.svg$")
EOF

make V=1 -j1
make DESTDIR="$1" install

rm -rf "$1/usr/lib/systemd"
